#ifndef WUBI86QUERY_H
#define WUBI86QUERY_H

#include <QObject>
#include <QQmlEngine>

#include <QtSql/QSqlDatabase>

class QSqlQuery;

class Wubi86Query : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
    Q_PROPERTY(QString roots READ roots NOTIFY rootsChanged)
    Q_PROPERTY(QString codes READ codes NOTIFY codesChanged)
    QML_ELEMENT
public:
    explicit Wubi86Query(QObject *parent = nullptr);

    QString query() {return _query;}
    void setQuery(QString query) {_query = query; emit queryChanged();}

    QString roots() {return _roots;}
    QString codes() {return _codes;}

    void newQuery();

signals:
    void queryChanged();
    void rootsChanged();
    void codesChanged();

private:
    QString _query;
    QString _roots;
    QString _codes;

    QSqlDatabase _db;
    QSqlQuery *_sqlquery;

signals:
};

#endif // WUBI86QUERY_H
